# Maintainer: Maxim Baz <archlinux at maximbaz dot com>
# Contributor: emersion <contact emersion.fr>

_name=browserpass-native
pkgname=browserpass
pkgver=3.1.0
pkgrel=1
pkgdesc="Native host app for Browserpass, browser extension for zx2c4's pass (password manager)"
arch=('loong64' 'x86_64')
url="https://github.com/${pkgname}/${_name}"
license=('ISC')
depends=('gnupg' 'glibc')
makedepends=('go' 'git')
optdepends=('browserpass-chromium: Chromium extension for Browserpass'
            'browserpass-firefox: Firefox extension for Browserpass')
source=("${pkgname}-${pkgver}.tar.gz::${url}/releases/download/${pkgver}/${_name}-${pkgver}-src.tar.gz"
        "${pkgname}-${pkgver}.tar.gz.asc::${url}/releases/download/${pkgver}/${_name}-${pkgver}-src.tar.gz.asc")
sha256sums=('7ab92d04aa136c69d993e3c2d81ee2d395480ab6556be3d45f5694edcc8024b5'
            'SKIP')
validpgpkeys=('56C3E775E72B0C8B1C0C1BD0B5DB77409B11B601')

prepare() {
    cd "${_name}-${pkgver}"
    make configure
}

build() {
    cd "${_name}-${pkgver}"

    # TODO The app doesn't use cgo, but disabling it breaks Full RELRO
    # export CGO_ENABLED=0
    export CGO_CPPFLAGS="${CPPFLAGS}"
    export CGO_CFLAGS="${CFLAGS}"
    export CGO_CXXFLAGS="${CXXFLAGS}"
    export CGO_LDFLAGS="${LDFLAGS}"
    export GOFLAGS="-buildmode=pie -trimpath -ldflags=-linkmode=external"
    go build -o browserpass
}

check() {
    cd "${_name}-${pkgver}"
    make test
}

package() {
    cd "${_name}-${pkgver}"
    make DESTDIR="${pkgdir}" install
}

# vim:set ts=4 sw=4 et:
